package top.codedance.iotp.server.net.handle.subhandle.controller.http.async;

import top.codedance.iotp.common.constent.Command;
import top.codedance.iotp.server.ServerApplication;
import top.codedance.iotp.server.net.handle.WsChannelHandler;
import top.codedance.iotp.server.net.handle.subhandle.controller.http.AbsractWsReceiveHandler;
import org.apache.log4j.Logger;

public class ComReceiverHandler extends AbsractWsReceiveHandler {
    private static final Logger logger = ServerApplication.getLogger(SystemReceiveHandler.class);

    @Override
    public void receive(String deviceId, String clientId, Integer instance, String data) {
        if(WsChannelHandler.wsIsActive(clientId)) {
            WsChannelHandler.wsSend(clientId, data);
        }else{
            releaseClosedWsService(deviceId, clientId, instance, Command.ASYNC_COM_COMMAND);
        }
        logger.debug("ComReceiverHandler");
    }
}
